package com.my.chapter15;

public class practice1 {
    public static void main(String[] args) {
        Holder<Pet> h = new Holder<>(new Cat());
        h.get();
        h.set(new Dog());
        h.get();
    }
}

class Pet{
    @Override
    public String toString() {
        return "Pet";
    }
}

class Cat extends Pet{
    @Override
    public String toString() {
        return "Cat";
    }
}

class Dog extends Pet{
    @Override
    public String toString() {
        return "Dog";
    }
}

class Holder<T>{
    private T a;
    public Holder(T a){
        this.a = a;
    }
    public void set(T a){
        this.a = a;
    }
    public T get(){
        System.out.println(a);
        return a;
    }
}

